package com.wang.model;

import java.util.Objects;

/**
 * 接口信息模型，存储Controller接口的详细信息（路径、HTTP方法、描述）
 */
public class ApiInfo {
    private final String path;         // 接口路径（如 /api/user）
    private final String httpMethod;   // HTTP方法（如 GET/POST）
    private final String description;  // 接口描述（Swagger注释）

    public ApiInfo(String path, String httpMethod, String description) {
        this.path = path;
        this.httpMethod = httpMethod;
        this.description = description;
    }

    // Getter方法
    public String getPath() { return path; }
    public String getHttpMethod() { return httpMethod; }
    public String getDescription() { return description; }

    // 重写equals确保接口去重（路径+HTTP方法唯一标识一个接口）
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ApiInfo apiInfo = (ApiInfo) o;
        return Objects.equals(path, apiInfo.path) &&
                Objects.equals(httpMethod, apiInfo.httpMethod);
    }

    @Override
    public int hashCode() {
        return Objects.hash(path, httpMethod);
    }

    @Override
    public String toString() {
        return httpMethod + " " + path + " - " + description;
    }
}
